export default [
    {
        //K
        path: '/home',
        //箭头函数:当路由被访问到的时候才会执行，当路由被访问的时候，路由组件才加载！！！
        component:()=>import('@/pages/Home'),
        //路由元信息:额外给当前路由注册一些信息
        meta: { show: true },
        //这里是配置对象：不能瞎写，人家让你书写的K.
    },
    {
        //在占位后面加上一个?,代表params参数，可以传递，也可以不传递
        path: '/search/:keyword?',
        component:()=>import('@/pages/Search'),
        meta: { show: true },
        name: 'search',
        //路由组件可以传递props，三种写法
        //第一种:对象写法
        //props:{erha:"二哈拆家",'taidi':'烦人'}
        //第二种想写法：布尔值
        //把路由当中的parmas参数作为props传递给路由组件
        // props:true,
        //第三种写法:函数写法
        //箭头函数返回的结果即为传递给路由组件的props【一般传递params、query参数】
        // props:route=>({a:route.params.keyword,b:route.query.k}) 
    }
    ,
    {
        path: '/login',
        component:()=>import('@/pages/Login'),
        meta: { show: false },
    }
    , {
        path: '/register',
        component:()=>import('@/pages/Register'),
        meta: { show: false },
    }
    ,
    //重定向
    {
        path: "/",
        redirect: '/home'
    }
    ,
    {
        //商品详情路由，需要带商品的id
        path:'/detail/:id?',
        component:()=>import('@/pages/Detail'),
        meta:{show:true}
    }
    ,
    {
        path:'/addcartsuccess',
        component:()=>import('@/pages/AddCartSuccess'),
        meta:{show:true}
    }
    ,
    {
        path:'/shopcart',
        component:()=>import('@/pages/ShopCart'),
        meta:{show:true}
    },
    {
        path:'/trade',
        component:()=>import('@/pages/Trade'),
        meta:{show:true},
        //路由独享守卫:只是负责当前路由的判断！！！
        beforeEnter:(to,from,next)=>{
           //如果你是从购物车而来->放行
           if(from.path=='/shopcart'){
                next();
           }else{
             //如果你从非购物车而来--->留在原地
             //如果浏览器的 URL 改变了 (可能是用户手动或者浏览器后退按钮)，那么 URL 地址会重置到 from 路由对应的地址。
             next(false);
           }
        }
    },
    {
        path:'/pay',
        component:()=>import('@/pages/Pay'),
        meta:{show:true},
        //路由独享守卫:只是负责支付路由判断！！！
        beforeEnter:(to,from,next)=>{
            //只有从交易路由才能跳转到支付路由里面
             if(from.path=='/trade'){
                 next();
             }else{
             //其他非交易路由跳转到支付页面，留在原地
                 next(false);
             }
        }
    },
    {
        path:'/paysuccess',
        component:()=>import('@/pages/PaySuccess'),
        meta:{show:true}
    },
    {
        path:'/center',
        component:()=>import('@/pages/Center'),
        meta:{show:true},
        children:[
            {
                path:'myorder',
                component:()=>import('@/pages/Center/myOrder')
            },
            {
                path:'grouporder',
                component:()=>import('@/pages/Center/groupOrder')
            },
            {
                path:'/center',
                redirect:'/center/myorder'
            }
        ]
    }
    ,
    {
        path: '/communication',
        component: () => import('@/pages/Communication/Communication'),
        children: [
          {
            path: 'event',
            component: () => import('@/pages/Communication/EventTest/EventTest'),
            meta: {
              isHideFooter: true
            },
          },
          {
            path: 'model',
            component: () => import('@/pages/Communication/ModelTest/ModelTest'),
            meta: {
              isHideFooter: true
            },
          },
          {
            path: 'sync',
            component: () => import('@/pages/Communication/SyncTest/SyncTest'),
            meta: {
              isHideFooter: true
            },
          },
          {
            path: 'attrs-listeners',
            component: () => import('@/pages/Communication/AttrsListenersTest/AttrsListenersTest'),
            meta: {
              isHideFooter: true
            },
          },
          {
            path: 'children-parent',
            component: () => import('@/pages/Communication/ChildrenParentTest/ChildrenParentTest'),
            meta: {
              isHideFooter: true
            },
          },
          {
            path: 'scope-slot',
            component: () => import('@/pages/Communication/ScopeSlotTest/ScopeSlotTest'),
            meta: {
              isHideFooter: true
            },
          }
        ],
      },
]